package com.ali.resource.CompoentPage;

import com.ali.resource.ShareTools.TeaopenapiClient;
import com.aliyun.amqp_open20191212.Client;
import com.aliyun.amqp_open20191212.models.ListInstancesRequest;
import com.aliyun.amqp_open20191212.models.ListInstancesResponse;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class RabbitMqComponent {

    @Autowired
    private TeaopenapiClient teaopenapiClient;

    public com.aliyun.amqp_open20191212.Client getRmClient() throws Exception {
        Config rmClient = teaopenapiClient.getClient();
        rmClient.setEndpoint("amqp-open.cn-shanghai.aliyuncs.com");
        return new Client(rmClient);
    }

    public com.aliyun.amqp_open20191212.models.ListInstancesResponse getRmResponse() throws Exception {
        ListInstancesRequest listInstancesRequest = new ListInstancesRequest();
        listInstancesRequest.setMaxResults(100);

        Client rmClient = this.getRmClient();
        ListInstancesResponse listInstancesResponse = rmClient.listInstancesWithOptions(listInstancesRequest, teaopenapiClient.getRunTime());
        return listInstancesResponse;

    }

}
